/*Copyright (C) 2013-2021 LZE*/
#include<bits/stdc++.h>
#define fo(x) freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout);
#define INF 0x7fffffff
#define mod 1000000007
#define eps 1e-6
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 2000010;
const int M = 100010;
string pattern, text;
ll prefix_table[N], len, tlen;
void make_prefix_table() {
    len = pattern.length();
    ll now, x;
    now = 0; x = 1;
    prefix_table[0] = 0;
    while(x < len) {
        if(pattern[now] == pattern[x]) {
            prefix_table[x] = now + 1;
            x++; now++;
        }
        else {
            while(now > 0 && pattern[now] != pattern[x])
                now = prefix_table[now - 1];
            if(pattern[now] != pattern[x]) {
                x++; now = 0;
            }
        }
    }
}
int main() {
#ifdef LOCAL
    fo(debug_data)
#endif
    cin >> text >> pattern;
    tlen = pattern.length();
    pattern += "%";
    pattern += text;
    make_prefix_table();
    for(ll i = tlen + 1; i <= len; i++) {
        if(prefix_table[i] == tlen) {
            printf("%lld\n", i - 2 * tlen + 1);
        }
    }
    for(ll i = 1; i <= tlen; i++) {
        printf("%lld ", prefix_table[i - 1]);
    }
    printf("\n");
    return 0;
}
